import request from '@/utils/request'

export function getRoles() {
  return request({
    url: '/roles',
    method: 'get'
  })
}

export function getRolesPage(data) {
  return request({
    url: '/roles/page',
    method: 'get',
    params: data
  })
}

export function createRole(data) {
  return request({
    url: '/roles',
    method: 'post',
    data
  })
}

export function updateRole(data) {
  return request({
    url: '/roles',
    method: 'put',
    data
  })
}

export function deleteRole(id) {
  return request({
    url: '/roles/' + id,
    method: 'delete'
  })
}

export function batchDeleteRole(data) {
  return request({
    url: '/roles/batch-delete',
    method: 'delete',
    data
  })
}

export function getRoleMenus(roleId) {
  return request({
    url: '/roles/menus/' + roleId,
    method: 'get'
  })
}

export function granted(data) {
  return request({
    url: '/roles/granted',
    method: 'put',
    data
  })
}
